import React from 'react';
import {Spin, Alert, Button, Icon} from 'antd';
import api from '../../axiox';

export default class MovieDetail extends React.Component {
    constructor(props) {
        super(props)
        this.state = {
            id: this.props.match.params.id,
            loading: true
        };
    }

    componentDidMount() {
        this.getDetail();
    }

    getDetail = () => {
        let url = `/v2/movie/subject/${this.state.id}`
        api({
            method: 'get',
            url,
            params: {
                apikey: "0df993c66c0c636e29ecbb5344252a4a"
            },

        }).then(res => {
            this.setState({
                movie:res.data,
                loading: false
            })
        })
    }

    render() {
        return (
            <div style={{padding: 5}}>
                <Spin spinning={this.state.loading}>
                    {this.state.loading ?
                        <Alert
                            message="加载中"
                            type="info"
                        />
                        :
                        <div>
                            <Button type="primary" onClick={()=>this.props.history.goBack()}>
                                <Icon type="left"/>
                                返回电影列表
                            </Button>
                            {/*todo 实现详情页面渲染*/}
                        </div>
                    }
                </Spin>
            </div>
        );
    }
}
